import book.Booklist;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024 —03 —05
 * Time: 19:39
 */
public class Main {
    public static User login(){
        System.out.println("请输入你的姓名");
        Scanner scanner = new Scanner(System.in);//实例化一个对象
        String name =scanner.nextLine();//完成了第一次人机交互，我输入进去的赋值给变量

        System.out.println("请输入你的身份1：管理员  2：普通用户");
        int choice = scanner.nextInt();//这是第二次交互

        if(choice == 1){
            return new AdminUser(name);
        }

        else {
            return new NormalUser(name);
        }

    }

    public static void main(String[] args) {
        Booklist booklist = new Booklist();//初始化


        User user = login();
        while (true){
            int choice = user.menu();
            System.out.println("choice:"+choice);//根据choice的选择来决定调用的是哪个方法？

            user.doOperation(choice,booklist);
        }

    }


}
